package com.sqly.doc.menu.tnb;

import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.adapter.CommonAdapter;
import com.sqly.doc.adapter.ViewHolder;
import com.sqly.doc.base.BaseHolder;
import com.sqly.doc.base.BaseRecyclerViewAdapter;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.ble.xty.ControlActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.pojo.BleEntity;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.pojo.Selected;
import com.sqly.doc.pojo.TnbHzsf;
import com.sqly.doc.pojo.Xx;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyApplication;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.ToastUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

//import cn.pedant.SweetAlert.SweetAlertDialog;
import com.vivachek.nova.bleproxy.BleProxy;
import com.vivachek.nova.bleproxy.BluetoothBroadcastReceiver;
import com.vivachek.nova.bleproxy.annotation.BleConnectState;
import com.vivachek.nova.bleproxy.entity.BaseBluetooth;

import cz.msebera.android.httpclient.Header;

/**
 * Created by Administrator on 2017/11/22 0022.
 */

public class tnb extends MyBaseActivity {
    EditText tz1, cys1, tz2, cys2, tz_qt,
            rxyl1, rxyl2, ryjl1, ryjl2,
            yd_ci1, yd_ci2, yd_fz1, yd_fz2,
            zs1, zs2,
            thxhdb,
            ywmc1, mr1, mc1,dw1,
            ywmc2, mr2, mc2,dw2,
            ywmc3, mr3, mc3,dw3,
            yds_zl, yds_mr, yds_mc,yds_dw,
            ywblfy_wu_des,
            tzywmc1, tzmr1, tzmc1, tzywdw1,
            tzywmc2, tzmr2, tzmc2, tzywdw2,
            tzywmc3, tzmr3, tzmc3, tzywdw3,
            zz_yy, zzjg, zz_lxr, zz_lxfs;
    EditText tz_yds_name, tz_yds_mr, tz_yds_mc, tz_yds_dw;
    TextView sfrq, jcrq, xcsfrq;
    EditText xy1, xy2, kfxtz,fzjc;
    RadioGroup sffs, zbdmbd, xltz, zyxw,
            fyycx, ywblfy,
            dtfy, ccsffl, xbglcs,
            zz, zzjieguo;
    String sffss = "";
    MultiLineChooseLayout zhengzhuang;
    Spinner zbdm_msg;
    String zbdm_msgs = "1";
    String JKDAH = "";
    private List<String> zhengzhuangdata = new ArrayList<>();
    //标题
    TextView title, uname, xm;

    TnbHzsf obj;
    private CustomDatePicker customDatePicker;
    Context con = tnb.this;
    List<Selected> slist = new ArrayList<>();
    JuMin j;
    private String url = "";
    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";
    boolean isadd = false;//是否是新添加
    private RecyclerView mRv;
    private TextView mTvResearch;
    private BaseRecyclerViewAdapter<BleEntity> mAdapter;
    private List<String> mScanMac = new ArrayList<>();
    public static final int PERMISSION = 1;
    LinearLayout back;

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;

    private BluetoothBroadcastReceiver mReceiver = new BluetoothBroadcastReceiver() {
        @Override
        protected void bluetoothDeviceDisconnected() {

        }

        @Override
        protected void bluetoothIsClose() {

        }

        @Override
        protected void bluetoothIsOpen() {
            BleProxy.getInstance().scan();
        }
    };
    @Override
    protected void initUI() {
        setContentView(R.layout.tnb);
        if (getIntent().getStringExtra("type").equals("edit")) {
            obj = (TnbHzsf) getIntent().getExtras().getSerializable("b");
            url = HttpUrl.EditGxyfsjl;
            initEditText();
            initRadioGroup();
            initMultiLineChooseLayout();
            initSpinner();
            if(!StringUtils.isEmpty(obj.getImg())){
                //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
            }
            if(!StringUtils.isEmpty(obj.getImg1())){
                //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
            }
            if(!StringUtils.isEmpty(obj.getImg2())){
                //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
            }
            xm.setClickable(false);
        } else {
            obj=new TnbHzsf();
            url = HttpUrl.AddGxyfsjl;
            initEditText();
            initRadioGroup();
            initMultiLineChooseLayout();
            initSpinner();
        }

        mRv = findViewById(R.id.rv);
        mTvResearch = findViewById(R.id.mTvResearch);
        mRv = findViewById(R.id.rv);
        mTvResearch.setText("正在搜索");
        mAdapter = new BaseRecyclerViewAdapter<BleEntity>(R.layout.item_search_ble) {

            @Override
            protected void convert(BaseHolder holder, BleEntity bleEntity) {
                holder.setIsRecyclable(false);
                holder.setText(R.id.tvDeviceName,
                        String.format(getString(R.string.device_name),
                                bleEntity.getBluetooth().getDevice().getName()));
                holder.setText(R.id.tvDeviceMac, String.format(getString(R.string.device_mac),
                        bleEntity.getBluetooth().getDevice().getAddress()));
                holder.setText(R.id.tvDeviceSn, String.format(getString(R.string.device_sn),
                        bleEntity.getBluetooth().getSn()));
                if (bleEntity.getState() == BleConnectState.DISCONNECTED) {
                    holder.setVisible(R.id.pb, View.GONE);
                } else if (bleEntity.getState() == BleConnectState.CONNECTING) {
                    holder.setVisible(R.id.pb, View.VISIBLE);
                    ProgressBar pb = holder.getViewById(R.id.pb);
                    pb.setIndeterminateDrawable(ActivityCompat.getDrawable(MyApplication.getApp(), R.drawable.anim_connecting));
                    pb.setProgressDrawable(ActivityCompat.getDrawable(MyApplication.getApp(),
                            R.drawable.anim_connecting));
                } else if (bleEntity.getState() == BleConnectState.CONNECT_SUCCESS) {
                    holder.setVisible(R.id.pb, View.VISIBLE);
                    ProgressBar pb = holder.getViewById(R.id.pb);
                    pb.setIndeterminateDrawable(ActivityCompat.getDrawable(MyApplication.getApp(),
                            R.drawable.connect_success));
                    pb.setProgressDrawable(ActivityCompat.getDrawable(MyApplication.getApp(),
                            R.drawable.connect_success));
                }
            }
        };
        mRv.setLayoutManager(new LinearLayoutManager(con));
        mRv.setAdapter(mAdapter);
        mRv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        mAdapter.setOnItemClickListener(new BaseRecyclerViewAdapter.OnItemClickListener<BleEntity>() {
            @Override
            public void onItemClick(BaseHolder holder, BleEntity bleEntity, int position) {
                for (BleEntity entity : mAdapter.getData()) {
                    entity.setState(BleConnectState.DISCONNECTED);
                }
                bleEntity.setState(BleConnectState.CONNECTING);
                mAdapter.notifyDataSetChanged();
                BleProxy.getInstance().connect(bleEntity.getBluetooth().getDevice().getAddress());
            }
        });
        mTvResearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /** 血糖测定统一使用个人信息模块血糖测定
                * scanBluetooth();
                 */
            }
        });

        back = (LinearLayout) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else if (requestCode == 1) {
            j = (JuMin) data.getExtras().getSerializable("j");
            getObject();
        }else if(requestCode == 19){
            BleProxy.getInstance().stopScan();
            String deviceVal = (String) data.getExtras().getString("deviceVal");
            kfxtz.setText(deviceVal);
            mTvResearch.setText("测定完成");
            mTvResearch.setClickable(true);
        }else if (requestCode == 8) {
            String record_id = (String) data.getExtras().getString("record_id");
            ysqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            sfysqm.setImageBitmap(bb);
            sfysqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if (requestCode == 9) {
            String record_id = (String) data.getExtras().getString("record_id");
            jmqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            brqm.setImageBitmap(bb);
            brqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if(requestCode == 119){
            String img_record_id = (String) data.getExtras().getString("img_record_id");
            pz_record_id.setText(img_record_id);
            pzChange = true;
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            xcqm.setImageBitmap(bb);
        }
    }

    private void initEditText() {
        //姓名
        xm = (TextView) findViewById(R.id.XINGMING);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING())) {
            xm.setText(obj.getXINGMING());
        } else {
            xm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(null == obj.getSFFS() || StringUtils.isEmpty(obj.getSFFS())){
                        SweetAlertDialogUtil.WarningDialog(con, "提示", "请先选择随访方式");
                    }else {
                        startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "tnb.class").putExtra("sffs", obj.getSFFS()), 1);
                    }
                }
            });
        }
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "tnbsf")
                        .putExtra("imageType", "img1")
                        .putExtra("class","tnb.class"), 8);
            }
        });
        //本人签名
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "tnbsf")
                        .putExtra("imageType", "img")
                        .putExtra("class","tnb.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
/**        血糖测定统一使用个人信息模块血糖测定
//        kfxtz.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                String xtyval = (String) SharedPreferencesUtils.getParam(con, "xtyval", "");
//                if(null == xtyval || "".equals(xtyval)) {
//                    SweetAlertDialogUtil.WarningDialog(con, "提示", "请点击用户输入框选择用户");
//                }else if (obj != null && StringUtils.isEmpty(obj.getXINGMING())) {
//                    SweetAlertDialogUtil.WarningDialog(con, "提示", "请点击用户输入框选择用户");
//                } else {
//                    for (BleEntity entity : mAdapter.getData()) {
//                        entity.setState(BleConnectState.DISCONNECTED);
//                        if(xtyval.equals(entity.getBluetooth().getDevice().getAddress()) ){
//                            entity.setState(BleConnectState.CONNECTING);
//                            BleProxy.getInstance().connect(entity.getBluetooth().getDevice().getAddress());
//                            break;
//                        }
//                    }
//                }
//            }
//        });
**/
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        title.setText("II型糖尿病患者随访服务记录");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null == obj.getSFFS() || StringUtils.isEmpty(obj.getSFFS())) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "请先选择随访方式");
                }else if(null == xm.getText().toString() || "".equals(xm.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "姓名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                }else if(null == sfrq.getText().toString() || "".equals(sfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访日期不能为空");
                } else if(null == xcsfrq.getText().toString() || "".equals(xcsfrq.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "下次随访日期不能为空");
                }else if("3".equals(obj.getSFFS()) && (null == xy1.getText().toString() || "".equals(xy1.getText().toString()) ||
                        null == xy2.getText().toString() || "".equals(xy2.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "血压值不能为空");
                } else if(("1".equals(obj.getSFFS()) || "2".equals(obj.getSFFS())) && (null == xy1.getText().toString() || "".equals(xy1.getText().toString()) ||
                        null == xy2.getText().toString() || "".equals(xy2.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "血压值不能为空,请点击“姓名”重新选择居民");
                } else if("3".equals(obj.getSFFS()) && (null == kfxtz.getText().toString() || "".equals(kfxtz.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "空腹血糖值不能为空");
                } else if(("1".equals(obj.getSFFS()) || "2".equals(kfxtz.getText().toString()) )&& (null == kfxtz.getText().toString() || "".equals(kfxtz.getText().toString()))){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "空腹血糖值不能为空,请点击“姓名”重新选择居民");
                }  else {
                    if (obj == null)
                        obj = new TnbHzsf();
                    obj.setSFRQ(sfrq.getText().toString());
                    ArrayList<Integer> zzlist = zhengzhuang.getAllItemSelectedIndex();
                    String zzs = "";
                    for (int i = 0; i < zzlist.size(); i++) {
//                        if (i == 0)
//                            zzs = zzlist.get(i) + "";
//                        else
//                            zzs = zzs + "," + zzlist.get(i);
                        if (i == 0)
                            zzs = (zzlist.get(i)+1) + "";
                        else
                            zzs = zzs + "," + (zzlist.get(i)+1);
                    }
                    obj.setZHENGZHUANG(zzs);
                    obj.setXUEYA1(xy1.getText().toString());
                    obj.setXUEYA2(xy2.getText().toString());
                    obj.setTIZHONG(tz1.getText().toString());
                    obj.setTIZHONGXC(tz2.getText().toString());
                    obj.setBMI(cys1.getText().toString());
                    obj.setBMIXC(cys2.getText().toString());
                    obj.setTZQT(tz_qt.getText().toString());
                    obj.setRXYL(rxyl1.getText().toString());
                    obj.setRXYLXC(rxyl2.getText().toString());
                    obj.setRYJL(ryjl1.getText().toString());
                    obj.setRYJLXC(ryjl2.getText().toString());
                    obj.setYDSC(yd_fz1.getText().toString());
                    obj.setYDSCXC(yd_fz2.getText().toString());
                    obj.setYDCS(yd_ci1.getText().toString());
                    obj.setYDCSXC(yd_ci2.getText().toString());

                    obj.setZSQK(zs1.getText().toString());
                    obj.setZSQKXC(zs2.getText().toString());
                    obj.setKFXT(kfxtz.getText().toString());
                    obj.setTHXHDB(thxhdb.getText().toString());
                    obj.setTHXHDBJCRQ(jcrq.getText().toString());
                    obj.setFZJCQT(fzjc.getText().toString());
                    obj.setYWMC1(ywmc1.getText().toString());
                    obj.setYWMC2(ywmc2.getText().toString());
                    obj.setYWMC3(ywmc3.getText().toString());
                    obj.setYWYF1(mr1.getText().toString());
                    obj.setYWYF2(mr2.getText().toString());
                    obj.setYWYF3(mr3.getText().toString());
                    obj.setYWYL1(mc1.getText().toString());
                    obj.setYWYL2(mc2.getText().toString());
                    obj.setYWYL3(mc3.getText().toString());
                    obj.setYWDW1(dw1.getText().toString());
                    obj.setYWDW2(dw2.getText().toString());
                    obj.setYWDW3(dw3.getText().toString());
                    obj.setYDSMC(yds_zl.getText().toString());
                    obj.setYDSYF(yds_mr.getText().toString());
                    obj.setYDSYL(yds_mc.getText().toString());
                    obj.setYDSDW(yds_dw.getText().toString());

                    obj.setTZYWMC1(tzywmc1.getText().toString());
                    obj.setTZYWMC2(tzywmc2.getText().toString());
                    obj.setTZYWMC3(tzywmc3.getText().toString());
                    obj.setTZYWYF1(tzmr1.getText().toString());
                    obj.setTZYWYF2(tzmr2.getText().toString());
                    obj.setTZYWYF3(tzmr3.getText().toString());
                    obj.setTZYWYL1(tzmc1.getText().toString());
                    obj.setTZYWYL2(tzmc2.getText().toString());
                    obj.setTZYWYL3(tzmc3.getText().toString());
                    obj.setTZYWDW1(tzywdw1.getText().toString());
                    obj.setTZYWDW2(tzywdw2.getText().toString());
                    obj.setTZYWDW3(tzywdw3.getText().toString());

                    obj.setTZYDSQTMC(tz_yds_name.getText().toString());
                    obj.setTZYDSQTYF(tz_yds_mr.getText().toString());
                    obj.setTZYDSQTYL(tz_yds_mc.getText().toString());
                    obj.setTZYDSQTDW(tz_yds_dw.getText().toString());

                    obj.setZZYY(zz_yy.getText().toString());
                    obj.setZZJGJKB(zzjg.getText().toString());
                    obj.setZZLXR(zz_lxr.getText().toString());
                    obj.setZZLXFS(zz_lxfs.getText().toString());
                    obj.setXCSFRQ(xcsfrq.getText().toString());

                    if (NetWorkUtils.isNetworkConnected(con)) {
                        RequestParams ps = new RequestParams();
                        ps.add("entity.CARDNUM",obj.getCARDNUM());
                        ps.add("entity.SFRQ", obj.getSFRQ());
                        ps.add("entity.SFFS", obj.getSFFS());
                        ps.add("entity.ZHENGZHUANG", obj.getZHENGZHUANG());
                        ps.add("entity.BMIXC", obj.getBMIXC());
                        ps.add("entity.XUEYA1", obj.getXUEYA1());
                        ps.add("entity.XUEYA2", obj.getXUEYA2());
                        ps.add("entity.TZQT", obj.getTZQT());
                        ps.add("entity.TIZHONG", obj.getTIZHONG());
                        ps.add("entity.TIZHONGXC", obj.getTIZHONGXC());
                        ps.add("entity.BMI", obj.getBMI());
                        ps.add("entity.BMIXC", obj.getBMIXC());
                        ps.add("entity.ZBDMBD", obj.getZBDMBD());
                        ps.add("entity.ZBDMBDYC", obj.getZBDMBDYC());
                        ps.add("entity.TZQT", obj.getTZQT());
                        ps.add("entity.RXYL", obj.getRXYL());
                        ps.add("entity.RXYLXC", obj.getRXYLXC());
                        ps.add("entity.RYJL", obj.getRYJL());
                        ps.add("entity.RYJLXC", obj.getRYJLXC());
                        ps.add("entity.YDCS", obj.getYDCS());
                        ps.add("entity.YDCSXC", obj.getYDCSXC());
                        ps.add("entity.YDSC", obj.getYDSC());
                        ps.add("entity.YDSCXC", obj.getYDSCXC());
                        ps.add("entity.ZSQK", obj.getZSQK());
                        ps.add("entity.ZSQKXC", obj.getZSQKXC());
                        ps.add("entity.XLTZ", obj.getXLTZ());
                        ps.add("entity.ZYXW", obj.getZYXW());
                        ps.add("entity.KFXT", obj.getKFXT());
                        ps.add("entity.THXHDB", obj.getTHXHDB());
                        ps.add("entity.THXHDBJCRQ", obj.getTHXHDBJCRQ());
                        ps.add("entity.FZJCQT", obj.getFZJCQT());
                        ps.add("entity.YWMC1", obj.getYWMC1());
                        ps.add("entity.YWYF1", obj.getYWYF1());
                        ps.add("entity.YWYL1", obj.getYWYL1());
                        ps.add("entity.YWDW1", obj.getYWDW1());
                        ps.add("entity.YWMC2", obj.getYWMC2());
                        ps.add("entity.YWMC2", obj.getYWMC2());
                        ps.add("entity.YWYF2", obj.getYWYF2());
                        ps.add("entity.YWDW2", obj.getYWDW2());
                        ps.add("entity.YWYL2", obj.getYWYL2());
                        ps.add("entity.YWMC3", obj.getYWMC3());
                        ps.add("entity.YWYF3", obj.getYWYF3());
                        ps.add("entity.YWYL3", obj.getYWYL3());
                        ps.add("entity.YWDW3", obj.getYWDW3());
                        ps.add("entity.YDSMC", obj.getYDSMC());
                        ps.add("entity.YDSYF", obj.getYDSYF());
                        ps.add("entity.YDSYL", obj.getYDSYL());
                        ps.add("entity.YDSDW", obj.getYDSDW());

                        ps.add("entity.FYYCX", obj.getFYYCX());
                        ps.add("entity.YWBLFY", obj.getYWBLFY());
                        ps.add("entity.DXTFY", obj.getDXTFY());
                        ps.add("entity.SFFL", obj.getSFFL());
                        ps.add("entity.XINGMING", obj.getXINGMING());
                        ps.add("entity.XYBGLCS", obj.getXYBGLCS());
                        ps.add("entity.TZYWMC1", obj.getTZYWMC1());
                        ps.add("entity.TZYWMC2", obj.getTZYWMC2());
                        ps.add("entity.TZYWMC3", obj.getTZYWMC3());
                        ps.add("entity.TZYWYF1", obj.getTZYWYF1());
                        ps.add("entity.TZYWYF2", obj.getTZYWYF2());
                        ps.add("entity.TZYWYF3", obj.getTZYWYF3());
                        ps.add("entity.TZYWYL1", obj.getTZYWYL1());
                        ps.add("entity.TZYWYL2", obj.getTZYWYL2());
                        ps.add("entity.TZYWYL3", obj.getTZYWYL3());
                        ps.add("entity.TZYWDW1", obj.getTZYWDW1());
                        ps.add("entity.TZYWDW2", obj.getTZYWDW2());
                        ps.add("entity.TZYWDW3", obj.getTZYWDW3());

                        ps.add("entity.TZYDSQTMC", obj.getTZYDSQTMC());
                        ps.add("entity.TZYDSQTYF", obj.getTZYDSQTYF());
                        ps.add("entity.TZYDSQTYL", obj.getTZYDSQTYL());
                        ps.add("entity.TZYDSQTDW", obj.getTZYDSQTDW());

                        ps.add("entity.ZZYY", obj.getZZYY());
                        ps.add("entity.ZZJGJKB", obj.getZZJGJKB());
                        ps.add("entity.ZZLXR", obj.getZZLXR());
                        ps.add("entity.ZZLXFS", obj.getZZLXFS());
                        ps.add("entity.ZZJG", obj.getZZJG());
                        ps.add("entity.SFZZ", obj.getSFZZ());
                        ps.add("entity.XCSFRQ", obj.getXCSFRQ());

                        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                        ps.add("type", "2");
                        if (isadd) {
                            ps.add("entity.JKDAH", JKDAH);
                            url = HttpUrl.AddTnbfsjl;
                        } else {
                            ps.add("entity.SFJLH", obj.getSFJLH());
                            ps.add("entity.JKDAH", obj.getJKDAH());
                            url = HttpUrl.SaveTnbfsjl;
                        }

                        ps.add("pz_record_id", pz_record_id.getText().toString());
                        ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                        ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                        //tnb.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                        UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                            @Override
                            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                                String content = new String(response);
                                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                                if (ret.getCode().equals("200")) {
                                    MyToastUtil.ShowToast(con, "成功");
                                }else{
                                    MyToastUtil.ShowToast(con, ret.getInfo());
                                }
                                finish();
                            }

                            @Override
                            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                                MyToastUtil.ShowToast(con, "失败");
                            }
                        });
                    }
                }
            }
        });
        //随访日期
        sfrq = (TextView) findViewById(R.id.sfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getSFRQ())) {
            sfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        sfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sfrq.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        //糖化血红蛋白检查日期
        jcrq = (TextView) findViewById(R.id.jcrq);
        if (obj != null && !StringUtils.isEmpty(obj.getTHXHDBJCRQ())) {
            jcrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getTHXHDBJCRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        jcrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        jcrq.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        //辅助检查
        fzjc = (EditText) findViewById(R.id.fzjc);
        if (obj != null && !StringUtils.isEmpty(obj.getFZJCQT())) {
            fzjc.setText(obj.getFZJCQT());
        }
        //
        xy1 = (EditText) findViewById(R.id.xy1);
        xy2 = (EditText) findViewById(R.id.xy2);
        //空腹血糖值
        kfxtz = (EditText) findViewById(R.id.kfxtz);
        if("1".equals(SharedPreferencesUtils.getParam(con, "tnbcj", "0").toString())){
            xy1.setEnabled(false);
            xy2.setEnabled(false);
            kfxtz.setEnabled(false);
        }else{
            xy1.setEnabled(true);
            xy2.setEnabled(true);
            kfxtz.setEnabled(true);
        }
        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA1())) {
            xy1.setText(obj.getXUEYA1());
        }
        //调整-胰岛素
        tz_yds_name = (EditText) findViewById(R.id.tz_yds_zl);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYDSQTMC())) {
            tz_yds_name.setText(obj.getTZYDSQTMC());
        }
        //每日
        tz_yds_mr = (EditText) findViewById(R.id.tz_yds_mr);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYDSQTYF())) {
            tz_yds_mr.setText(obj.getTZYDSQTYF());
        }
        //每次
        tz_yds_mc = (EditText) findViewById(R.id.tz_yds_mc);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYDSQTYL())) {
            tz_yds_mc.setText(obj.getTZYDSQTYL());
        }
        tz_yds_dw = (EditText) findViewById(R.id.tz_yds_dw);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYDSQTDW())) {
            tz_yds_dw.setText(obj.getTZYDSQTDW());
        }

        if (obj != null && !StringUtils.isEmpty(obj.getXUEYA2())) {
            xy2.setText(obj.getXUEYA2());
        }
        tz1 = (EditText) findViewById(R.id.tz1);
        if (obj != null && !StringUtils.isEmpty(obj.getTIZHONG())) {
            tz1.setText(obj.getTIZHONG());
        }
        tz2 = (EditText) findViewById(R.id.tz2);
        if (obj != null && !StringUtils.isEmpty(obj.getTIZHONGXC())) {
            tz2.setText(obj.getTIZHONGXC());
        }
        cys1 = (EditText) findViewById(R.id.cys1);
        if (obj != null && !StringUtils.isEmpty(obj.getBMI())) {
            cys1.setText(obj.getBMI());
        }
        cys2 = (EditText) findViewById(R.id.cys2);
        if (obj != null && !StringUtils.isEmpty(obj.getBMIXC())) {
            cys2.setText(obj.getBMIXC());
        }
        //体征-其他
        tz_qt = (EditText) findViewById(R.id.tz_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getTZQT())) {
            tz_qt.setText(obj.getTZQT());
        }
        //日吸烟量
        rxyl1 = (EditText) findViewById(R.id.rxyl1);
        if (obj != null && !StringUtils.isEmpty(obj.getRXYL())) {
            rxyl1.setText(obj.getRXYL());
        }
        //日吸烟量
        rxyl2 = (EditText) findViewById(R.id.rxyl2);
        if (obj != null && !StringUtils.isEmpty(obj.getRXYLXC())) {
            rxyl2.setText(obj.getRXYLXC());
        }
        //日饮酒量
        ryjl1 = (EditText) findViewById(R.id.ryjl1);
        if (obj != null && !StringUtils.isEmpty(obj.getRYJL())) {
            ryjl1.setText(obj.getRYJL());
        }
        //日饮酒量
        ryjl2 = (EditText) findViewById(R.id.ryjl2);
        if (obj != null && !StringUtils.isEmpty(obj.getRYJLXC())) {
            ryjl2.setText(obj.getRYJLXC());
        }
        //运动-次/周
        yd_ci1 = (EditText) findViewById(R.id.yd_ci1);
        if (obj != null && !StringUtils.isEmpty(obj.getYDCS())) {
            yd_ci1.setText(obj.getYDCS());
        }
        //运动-次/周
        yd_ci2 = (EditText) findViewById(R.id.yd_ci2);
        if (obj != null && !StringUtils.isEmpty(obj.getYDCSXC())) {
            yd_ci2.setText(obj.getYDCSXC());
        }
        //运动-分钟/次
        yd_fz1 = (EditText) findViewById(R.id.yd_fz1);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSC())) {
            yd_fz1.setText(obj.getYDSC());
        }
        //运动-分钟/次
        yd_fz2 = (EditText) findViewById(R.id.yd_fz2);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSCXC())) {
            yd_fz2.setText(obj.getYDSCXC());
        }
        //主食
        zs1 = (EditText) findViewById(R.id.zs1);
        if (obj != null && !StringUtils.isEmpty(obj.getZSQK())) {
            zs1.setText(obj.getZSQK());
        }
        //主食
        zs2 = (EditText) findViewById(R.id.zs2);
        if (obj != null && !StringUtils.isEmpty(obj.getZSQKXC())) {
            zs2.setText(obj.getZSQKXC());
        }
        if (obj != null && !StringUtils.isEmpty(obj.getKFXT())) {
            kfxtz.setText(obj.getKFXT());
        }
        //糖化血红蛋白
        thxhdb = (EditText) findViewById(R.id.thxhdb);
        if (obj != null && !StringUtils.isEmpty(obj.getTHXHDB())) {
            thxhdb.setText(obj.getTHXHDB());
        }
        //检查日期
        jcrq = (TextView) findViewById(R.id.jcrq);
        jcrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        jcrq.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });

        //目前用药情况-药物1
        ywmc1 = (EditText) findViewById(R.id.ywmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC1())) {
            ywmc1.setText(obj.getYWMC1());
        }
        mr1 = (EditText) findViewById(R.id.mr1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF1())) {
            mr1.setText(obj.getYWYF1());
        }
        mc1 = (EditText) findViewById(R.id.mc1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF1())) {
            mc1.setText(obj.getYWYL1());
        }
        dw1= (EditText) findViewById(R.id.dw1);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW1())) {
            dw1.setText(obj.getYWDW1());
        }
        //目前用药情况-药物2
        ywmc2 = (EditText) findViewById(R.id.ywmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC2())) {
            ywmc2.setText(obj.getYWMC2());
        }
        mr2 = (EditText) findViewById(R.id.mr2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF2())) {
            mr2.setText(obj.getYWYF2());
        }
        mc2 = (EditText) findViewById(R.id.mc2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYL2())) {
            mc2.setText(obj.getYWYL2());
        }
        dw2= (EditText) findViewById(R.id.dw2);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW2())) {
            dw2.setText(obj.getYWDW2());
        }
        //目前用药情况-药物3
        ywmc3 = (EditText) findViewById(R.id.ywmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWMC3())) {
            ywmc3.setText(obj.getYWMC3());
        }
        mr3 = (EditText) findViewById(R.id.mr3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYF3())) {
            mr3.setText(obj.getYWYF3());
        }
        mc3 = (EditText) findViewById(R.id.mc3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWYL3())) {
            mc3.setText(obj.getYWYL3());
        }
        dw3= (EditText) findViewById(R.id.dw3);
        if (obj != null && !StringUtils.isEmpty(obj.getYWDW3())) {
            dw3.setText(obj.getYWDW3());
        }
        //胰岛素-种类
        yds_zl = (EditText) findViewById(R.id.yds_zl);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSMC())) {
            yds_zl.setText(obj.getYDSMC());
        }
        //胰岛素-每日
        yds_mr = (EditText) findViewById(R.id.yds_mr);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSYF())) {
            yds_mr.setText(obj.getYDSYF());
        }
        //胰岛素-每次
        yds_mc = (EditText) findViewById(R.id.yds_mc);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSYL())) {
            yds_mc.setText(obj.getYDSYL());
        }
        yds_dw = (EditText) findViewById(R.id.yds_dw);
        if (obj != null && !StringUtils.isEmpty(obj.getYDSDW())) {
            yds_dw.setText(obj.getYDSDW());
        }
        //药物不良反应-选择“有”填写内容【未找到对应字段】
        ywblfy_wu_des = (EditText) findViewById(R.id.ywblfy_wu_des);
        if (obj != null && !StringUtils.isEmpty(obj.getYWBLFY())) {
            ywblfy_wu_des.setText(obj.getYWBLFY());
        }

        //调整用药情况-药物1-名称
        tzywmc1 = (EditText) findViewById(R.id.tzywmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC1())) {
            tzywmc1.setText(obj.getTZYWMC1());
        }
        //-药物1-用法
        tzmr1 = (EditText) findViewById(R.id.tzmr1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF1())) {
            tzmr1.setText(obj.getTZYWYF1());
        }
        //-药物1-每次剂量
        tzmc1 = (EditText) findViewById(R.id.tzmc1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL1())) {
            tzmc1.setText(obj.getTZYWYL1());
        }
        tzywdw1= (EditText) findViewById(R.id.tzywdw1);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW1())) {
            tzywdw1.setText(obj.getTZYWDW1());
        }
        //调整用药情况-药物2-名称
        tzywmc2 = (EditText) findViewById(R.id.tzywmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC2())) {
            tzywmc2.setText(obj.getTZYWMC2());
        }
        //-药物2-用法
        tzmr2 = (EditText) findViewById(R.id.tzmr2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF2())) {
            tzmr2.setText(obj.getTZYWYF2());
        }
        //-药物2-每次剂量
        tzmc2 = (EditText) findViewById(R.id.tzmc2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL2())) {
            tzmc2.setText(obj.getTZYWYL2());
        }
        tzywdw2= (EditText) findViewById(R.id.tzywdw2);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW2())) {
            tzywdw2.setText(obj.getTZYWDW2());
        }
        //调整用药情况-药物3-名称
        tzywmc3 = (EditText) findViewById(R.id.tzywmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWMC3())) {
            tzywmc3.setText(obj.getTZYWMC3());
        }
        //-药物3-用法
        tzmr3 = (EditText) findViewById(R.id.tzmr3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYF3())) {
            tzmr3.setText(obj.getTZYWYF3());
        }
        //-药物3-每次剂量
        tzmc3 = (EditText) findViewById(R.id.tzmc3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWYL3())) {
            tzmc3.setText(obj.getTZYWYL3());
        }
        tzywdw3= (EditText) findViewById(R.id.tzywdw3);
        if (obj != null && !StringUtils.isEmpty(obj.getTZYWDW3())) {
            tzywdw3.setText(obj.getTZYWDW3());
        }
        //转诊原因
        zz_yy = (EditText) findViewById(R.id.zz_yy);
        if (obj != null && !StringUtils.isEmpty(obj.getZZYY())) {
            zz_yy.setText(obj.getZZYY());
        }
        //转诊机构及科室
        zzjg = (EditText) findViewById(R.id.zzjg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJGJKB())) {
            zzjg.setText(obj.getZZJGJKB());
        }
        //转诊联系人
        zz_lxr = (EditText) findViewById(R.id.zz_lxr);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXR())) {
            zz_lxr.setText(obj.getZZLXR());
        }
        //转诊联系方式
        zz_lxfs = (EditText) findViewById(R.id.zz_lxfs);
        if (obj != null && !StringUtils.isEmpty(obj.getZZLXFS())) {
            zz_lxfs.setText(obj.getZZLXFS());
        }

        //下次随访日期
        xcsfrq = (TextView) findViewById(R.id.xcsfrq);
        if (obj != null && !StringUtils.isEmpty(obj.getXCSFRQ())) {
            xcsfrq.setText(DateConvert.dateToString(DateConvert.toDate(obj.getXCSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        xcsfrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        xcsfrq.setText(time.split(" ")[0]);
                    }
                }, DateConvert.getCustomDatePickerStartRq(), DateConvert.getCustomDatePickerEndRq()); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(DateConvert.getCustomDatePickerStartRq());
            }
        });
    }

    private void initRadioGroup() {
        sffs = (RadioGroup) findViewById(R.id.sffs);
        if (obj != null && !StringUtils.isEmpty(obj.getSFFS())) {
            switch (Integer.parseInt(obj.getSFFS())) {
                case 1:
                    sffs.check(R.id.sffs_mz);
                    break;
                case 2:
                    sffs.check(R.id.sffs_jt);
                    break;
                case 3:
                    sffs.check(R.id.sffs_dh);
                    break;
            }
        }
        sffs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.sffs_mz) {
                    sffss = "1";
                    if(getIntent().getStringExtra("type").equals("edit")){
//                        xy1.setText("");
//                        xy2.setText("");
//                        kfxtz.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        kfxtz.setEnabled(false);
                    }else {
                        xy1.setText("");
                        xy2.setText("");
                        kfxtz.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        kfxtz.setEnabled(false);
                    }
                }
                if (i == R.id.sffs_jt) {
                    sffss = "2";
                    if(getIntent().getStringExtra("type").equals("edit") ){
//                        xy1.setText("");
//                        xy2.setText("");
//                        kfxtz.setText("");
                        xy1.setEnabled(false);
                        xy2.setEnabled(false);
                        kfxtz.setEnabled(false);
                    }else {
                        xy1.setText("");
                        xy2.setText("");
                        kfxtz.setText("");
                    }
                }
                if (i == R.id.sffs_dh) {
                    sffss = "3";
                    xy1.setEnabled(true);
                    xy2.setEnabled(true);
                    kfxtz.setEnabled(true);
                    xy1.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                    xy2.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
                    kfxtz.setInputType(8194);
                }
                obj.setSFFS(sffss);
            }
        });

        //足背动脉搏动
        zbdmbd = (RadioGroup) findViewById(R.id.zbdmbd);
        if (obj != null && !StringUtils.isEmpty(obj.getZBDMBD())) {
            Log.i("obj.getZBDMBD()","=="+obj.getZBDMBD());
            switch (Integer.parseInt(obj.getZBDMBD())) {
                case 1:
                    zbdmbd.check(R.id.zbdmbd1);
                    break;
                case 2:
                    zbdmbd.check(R.id.zbdmbd2);
                    break;
                case 3:
                    zbdmbd.check(R.id.zbdmbd3);
                    break;
            }
        }
        zbdmbd.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.zbdmbd1)
                    obj.setZBDMBD("1");
                if (checkedId == R.id.zbdmbd2)
                    obj.setZBDMBD("2");
                if (checkedId == R.id.zbdmbd3)
                    obj.setZBDMBD("3");
            }
        });
        //心理调整
        xltz = (RadioGroup) findViewById(R.id.xltz);
        if (obj != null && !StringUtils.isEmpty(obj.getXLTZ())) {
            switch (Integer.parseInt(obj.getXLTZ())) {
                case 1:
                    xltz.check(R.id.xltz_lh);
                    break;
                case 2:
                    xltz.check(R.id.xltz_yb);
                    break;
                case 3:
                    xltz.check(R.id.xltz_c);
                    break;
            }
        }
        xltz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.xltz_lh)
                    obj.setXLTZ("1");
                if (checkedId == R.id.xltz_yb)
                    obj.setXLTZ("2");
                if (checkedId == R.id.xltz_c)
                    obj.setXLTZ("3");
            }
        });
        //遵医行为
        zyxw = (RadioGroup) findViewById(R.id.zyxw);
        if (obj != null && !StringUtils.isEmpty(obj.getZYXW())) {
            switch (Integer.parseInt(obj.getZYXW())) {
                case 1:
                    zyxw.check(R.id.zyxw_lh);
                    break;
                case 2:
                    zyxw.check(R.id.zyxw_yb);
                    break;
                case 3:
                    zyxw.check(R.id.zyxw_c);
                    break;
            }
        }
        zyxw.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.zyxw_lh)
                    obj.setZYXW("1");
                if (checkedId == R.id.zyxw_yb)
                    obj.setZYXW("2");
                if (checkedId == R.id.zyxw_c)
                    obj.setZYXW("3");
            }
        });
        //用药依从性
        fyycx = (RadioGroup) findViewById(R.id.fyycx);
        if (obj != null && !StringUtils.isEmpty(obj.getFYYCX())) {
            switch (Integer.parseInt(obj.getFYYCX())) {
                case 1:
                    fyycx.check(R.id.fyycx_l);
                    break;
                case 2:
                    fyycx.check(R.id.fyycx_jd);
                    break;
                case 3:
                    fyycx.check(R.id.fyycx_bfy);
                    break;
            }
        }
        fyycx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.fyycx_l)
                    obj.setFYYCX("1");
                if (checkedId == R.id.fyycx_jd)
                    obj.setFYYCX("2");
                if (checkedId == R.id.fyycx_bfy)
                    obj.setFYYCX("3");
            }
        });
        //药物不良反应
        ywblfy = (RadioGroup) findViewById(R.id.ywblfy);
        if (obj != null && !StringUtils.isEmpty(obj.getYWBLFY())) {
            switch (Integer.parseInt(obj.getYWBLFY())) {
                case 1:
                    ywblfy.check(R.id.ywblfy_wu);
                    break;
                case 2:
                    ywblfy.check(R.id.ywblfy_you);
                    break;
            }
        }
        ywblfy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.ywblfy_wu)
                    obj.setYWBLFY("1");
                if (checkedId == R.id.ywblfy_you)
                    obj.setYWBLFY("2");
            }
        });
        //低血糖反应
        dtfy = (RadioGroup) findViewById(R.id.dtfy);
        if (obj != null && !StringUtils.isEmpty(obj.getDXTFY())) {
            switch (Integer.parseInt(obj.getDXTFY())) {
                case 1:
                    dtfy.check(R.id.dtfy_wu);
                    break;
                case 2:
                    dtfy.check(R.id.dtfy_oe);
                    break;
                case 3:
                    dtfy.check(R.id.dtfy_pf);
                    break;
            }
        }
        dtfy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.dtfy_wu)
                    obj.setDXTFY("1");
                if (checkedId == R.id.dtfy_oe)
                    obj.setDXTFY("2");
                if (checkedId == R.id.dtfy_pf)
                    obj.setDXTFY("3");
            }
        });
        //此次随访分类
        ccsffl = (RadioGroup) findViewById(R.id.ccsffl);
        if (obj != null && !StringUtils.isEmpty(obj.getSFFL())) {
            switch (Integer.parseInt(obj.getSFFL())) {
                case 1:
                    ccsffl.check(R.id.ccsffl_my);
                    break;
                case 2:
                    ccsffl.check(R.id.ccsffl_bmy);
                    break;
                case 3:
                    ccsffl.check(R.id.ccsffl_blfy);
                    break;
                case 4:
                    ccsffl.check(R.id.ccsffl_bfz);
                    break;
            }
        }else{
//            ccsffl.check(R.id.ccsffl_my);
        }
        ccsffl.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.ccsffl_my)
                    obj.setSFFL("1");
                if (checkedId == R.id.ccsffl_bmy)
                    obj.setSFFL("2");
                if (checkedId == R.id.ccsffl_blfy)
                    obj.setSFFL("3");
                if (checkedId == R.id.ccsffl_bfz)
                    obj.setSFFL("4");
            }
        });
        //下一步管理措施
        xbglcs = (RadioGroup) findViewById(R.id.xbglcs);
        if (obj != null && !StringUtils.isEmpty(obj.getXYBGLCS())) {
            switch (Integer.parseInt(obj.getXYBGLCS())) {
                case 1:
                    xbglcs.check(R.id.xbglcs_cgsf);
                    break;
                case 2:
                    xbglcs.check(R.id.xbglcs_dycbmy);
                    break;
                case 3:
                    xbglcs.check(R.id.xbglcs_liangci);
                    break;
                case 4:
                    xbglcs.check(R.id.xbglcs_jjzz);
                    break;
            }
        }else{
//            xbglcs.check(R.id.xbglcs_cgsf);
        }
        xbglcs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.xbglcs_cgsf)
                    obj.setXYBGLCS("1");
                if (checkedId == R.id.xbglcs_dycbmy)
                    obj.setXYBGLCS("2");
                if (checkedId == R.id.xbglcs_liangci)
                    obj.setXYBGLCS("3");
                if (checkedId == R.id.xbglcs_jjzz)
                    obj.setXYBGLCS("4");
            }
        });

        //是否需要转诊
        zz = (RadioGroup) findViewById(R.id.zz);
        if (obj != null && !StringUtils.isEmpty(obj.getSFZZ())) {
            switch (Integer.parseInt(obj.getSFZZ())) {
                case 1:
                    zz.check(R.id.zz_wu);
                    break;
                case 2:
                    zz.check(R.id.zz_you);
                    break;
            }
        }
        zz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.zz_wu)
                    obj.setSFZZ("1");
                if (checkedId == R.id.zz_you)
                    obj.setSFZZ("2");
            }
        });
        //转诊结果
        zzjieguo = (RadioGroup) findViewById(R.id.jg);
        if (obj != null && !StringUtils.isEmpty(obj.getZZJG())) {
            switch (Integer.parseInt(obj.getZZJG())) {
                case 1:
                    zzjieguo.check(R.id.dw);
                    break;
                case 2:
                    zzjieguo.check(R.id.wdw);
                    break;
            }
        }
        zzjieguo.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.dw)
                    obj.setZZJG("1");
                if (checkedId == R.id.wdw)
                    obj.setZZJG("2");
            }
        });

    }

    /***
     * 初始化initMultiLineChooseLayout组件
     */
    private void initMultiLineChooseLayout() {
        //目前症状
        zhengzhuang = (MultiLineChooseLayout) findViewById(R.id.zhengzhuang);
        zhengzhuangdata.add("无症状");
        zhengzhuangdata.add("多饮");
        zhengzhuangdata.add("多食");
        zhengzhuangdata.add("多尿");
        zhengzhuangdata.add("视力模糊");
        zhengzhuangdata.add("感染");
        zhengzhuangdata.add("手脚麻木");
        zhengzhuangdata.add("下肢浮肿");
        zhengzhuangdata.add("体重明显下降");
        zhengzhuangdata.add("其他");
        zhengzhuang.setList(zhengzhuangdata);
        if (obj != null && !StringUtils.isEmpty(obj.getZHENGZHUANG())) {
//            if (obj.getZHENGZHUANG().contains(",")) {
//                String[] ss = obj.getZHENGZHUANG().split(",");
//                for (int i = 0; i < ss.length; i++) {
//                    if (!StringUtils.isEmpty(ss[i])) {
//                        zhengzhuang.setIndexItemSelected(Integer.parseInt(ss[i]));
//                    }
//                }
//            } else {
//                zhengzhuang.setIndexItemSelected(Integer.parseInt(obj.getZHENGZHUANG()));
//            }
            if (obj != null && !StringUtils.isEmpty(obj.getZHENGZHUANG())) {
                if (obj.getZHENGZHUANG().contains(",")) {
                    String[] ss = obj.getZHENGZHUANG().split(",");
                    for (int i = 0; i < ss.length; i++) {
                        if (!StringUtils.isEmpty(ss[i])) {
                            if(Integer.parseInt(ss[i])==0){
                                zhengzhuang.setIndexItemSelected(Integer.parseInt(ss[i]));
                            }else{
                                zhengzhuang.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                            }
                        }
                    }
                } else {
                    if(Integer.parseInt(obj.getZHENGZHUANG())==0){
                        zhengzhuang.setIndexItemSelected(Integer.parseInt(obj.getZHENGZHUANG()));
                    }else{
                        zhengzhuang.setIndexItemSelected(Integer.parseInt(obj.getZHENGZHUANG())-1);
                    }

                }
            }
        }
    }

    /***
     * 初始化Spinner组件
     */
    private void initSpinner() {
        zbdm_msg = (Spinner) findViewById(R.id.zbdm_msg);
        Resources res = getResources();
        String[] jydic = res.getStringArray(R.array.tnb_zbdmbd_shuangce);
        List<Xx> jylist = new ArrayList<Xx>();
        for (int i = 0; i < jydic.length; i++) {
            Xx x = new Xx();
            x.setName(jydic[i]);
            jylist.add(x);
        }
        zbdm_msg.setAdapter(new CommonAdapter<Xx>(tnb.this, jylist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        zbdm_msg.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                zbdm_msgs = (position + 1) + "";
                obj.setZBDMBDYC(zbdm_msgs);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        if (obj != null && !StringUtils.isEmpty(obj.getZBDMBDYC())) {
            zbdm_msg.setSelection(Integer.parseInt(obj.getZBDMBDYC()) - 1);
        }

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        ps.add("sfrq", sfrq.getText().toString());
        ps.add("sffs", obj.getSFFS());

        UserClient.get(HttpUrl.GetTnbfsjlGrjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                Log.i("ycf2", content);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    if (StringUtils.isEmpty(ret.getOtherParams())) {//other是空的
                        JSONObject j = JSON.parseObject(ret.getRd());
                        obj = new TnbHzsf();
                        obj.setJKDAH(j.getString("JKDAH"));
                        obj.setXINGMING(j.getString("XINGMING"));
                        obj.setCARDNUM(j.getString("CARDNUM"));
                        obj.setSFFS(sffss);
                        JKDAH = j.getString("JKDAH");
                        xm.setText(j.getString("XINGMING"));
                        kfxtz.setText(j.getString("XTZ"));
                        xy1.setText(j.getString("XYZ1"));
                        xy2.setText(j.getString("XYZ2"));

                        isadd = true;
                    } else {
                        obj = JSON.parseObject(ret.getRd(), TnbHzsf.class);
                        xm.setText("");
                        kfxtz.setText("");
                        xy1.setText("");
                        xy2.setText("");
                    }
                } else {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", ret.getInfo());
                }
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                isadd = true;
                obj = new TnbHzsf();
            }
        });
    }


    @Override
    protected void onResume() {
        super.onResume();
        IntentFilter filter = new IntentFilter();
//		监视蓝牙关闭和打开的状态
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
//		监视蓝牙设备与APP连接的状态
        filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
        registerReceiver(mReceiver,filter);


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int bluetooth = ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH);
            int bluetoothAdmin = ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.BLUETOOTH_ADMIN);
            int location = ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION);
            if (bluetooth == PackageManager.PERMISSION_GRANTED && bluetoothAdmin == PackageManager.PERMISSION_GRANTED && location == PackageManager.PERMISSION_GRANTED) {
                scanBluetooth();
            } else {
                requestPermissions(new String[]{Manifest.permission.BLUETOOTH,
                        Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION);
            }

        }else {
            scanBluetooth();
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mReceiver);
    }
    private void scanBluetooth() {
        mScanMac.clear();
        mAdapter.clearData();
        mAdapter.notifyDataSetChanged();
        if (BleProxy.getInstance().isBleEnable()) {
            BleProxy.getInstance().scan();
        }else {
            BleProxy.getInstance().enableBle();
        }
    }

    @Override
    public void onScanStart() {
        super.onScanStart();
        mTvResearch.setText(getString(R.string.searching));
        mTvResearch.setClickable(false);
    }

    @Override
    public void onScanFinish(List<BaseBluetooth> scanResultList) {
        super.onScanFinish(scanResultList);
        if(null != mTvResearch.getText() && !"设备正常".equals(mTvResearch.getText())) {
            mTvResearch.setText(getString(R.string.research));
        }
        mTvResearch.setClickable(true);
    }

    @Override
    public void onScanning(BaseBluetooth bleDevice) {
        Log.i("onScanning","================2");
        super.onScanning(bleDevice);
        if (bleDevice == null) {
            return;
        }
        String mac = bleDevice.getDevice().getAddress();
        String name = bleDevice.getDevice().getName();
        if (TextUtils.isEmpty(mac) || TextUtils.isEmpty(name)) {
            return;
        }
        BleEntity bleEntity = new BleEntity(bleDevice, BleConnectState.DISCONNECTED);
        boolean isNotify = false;
        if (mScanMac.contains(mac)) {
            for (BleEntity entity : mAdapter.getData()) {
                if (entity.getBluetooth().getDevice().getAddress().equals(mac)) {
                    String sn = entity.getBluetooth().getSn();
                    if (TextUtils.isEmpty(sn)) {
                        entity.getBluetooth().setSn(bleDevice.getSn());
                        isNotify = true;
                        break;
                    }
                }
            }
            if (isNotify) {
                mAdapter.notifyDataSetChanged();
            }
        } else {
            mScanMac.add(mac);
            mAdapter.addData(bleEntity);
            mAdapter.notifyDataSetChanged();
        }
        String xtyval = (String) SharedPreferencesUtils.getParam(con, "xtyval", "");
        if(null == xtyval || "".equals(xtyval)) {
            SweetAlertDialogUtil.WarningDialog(con, "提示", "请点击用户输入框选择用户");
        }else {
            for (BleEntity entity : mAdapter.getData()) {
                if (xtyval.equals(entity.getBluetooth().getDevice().getAddress())) {
                    mTvResearch.setText("设备正常");
                    break;
                }
            }
        }
    }

    @Override
    public void onConnectSuccess(BaseBluetooth bleDevice) {
        Log.i("onConnectSuccess","================1");
        super.onConnectSuccess(bleDevice);
        for (BleEntity entity : mAdapter.getData()) {
            if (entity.getBluetooth().getDevice().getAddress().equals(bleDevice.getDevice().getAddress())) {
                entity.setState(BleConnectState.CONNECT_SUCCESS);
            } else {
                entity.setState(BleConnectState.DISCONNECTED);
            }
        }
        mAdapter.notifyDataSetChanged();
        BleProxy.getInstance().notify(bleDevice);

    }

    @Override
    public void openNotifySuccess(BaseBluetooth bleDevice) {
        Log.i("openNotifySuccess","================3");
        super.openNotifySuccess(bleDevice);
        Intent intent = new Intent(this, ControlActivity.class);
        intent.putExtra(ControlActivity.DEVICE, (Serializable) bleDevice);
        startActivityForResult(intent, 19);
    }

    @Override
    public void openNotifyFail() {
        super.openNotifyFail();
        for (BleEntity entity : mAdapter.getData()) {
            entity.setState(BleConnectState.DISCONNECTED);
        }
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onConnectFail(String mac) {
        super.onConnectFail(mac);
        for (BleEntity entity : mAdapter.getData()) {
            entity.setState(BleConnectState.DISCONNECTED);
        }
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == PERMISSION) {
            for (int i = 0; i < permissions.length; i++) {
                if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
                    ToastUtil.showShortToast(MyApplication.getApp(), getString(R.string.permission_denied));
                    return;
                }
            }
            scanBluetooth();
        } else {
            ToastUtil.showShortToast(MyApplication.getApp(), getString(R.string.permission_denied));
        }
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
                }else {
                    Intent intent = new Intent(con, CameraChoose.class)
                            .putExtra("type", "edit")
                            .putExtra("cardnum", obj.getCARDNUM())
                            .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                            .putExtra("tabType", "tnbsf")
                            .putExtra("class", "tnb.class");
                    startActivityForResult(intent, 119);
                }
            }
        }
    }
}
